<?php
	namespace Api\Model;
	use Think\Model;
	class UserModel extends Model
	{
		//检查验证码
		public function checkCode($tel, $code)
		{
			$codeinfo = $this -> getBytel($tel);
			if ($codeinfo['code'] != $code)
			{
				$array['result'] = -3;
				$array['message'] = "验证码不正确！";
				echo json_encode($array, JSON_UNESCAPED_SLASHES);
				exit;
			}
			elseif ((time() - $codeinfo['sttime']) > 60)
			{
				$array['result'] = -4;
				$array['message'] = "验证码过期！";
				echo json_encode($array, JSON_UNESCAPED_SLASHES);
				exit;
			}
		}
		//更改密码
		public function modifyPassword($uid, $oldpassword, $newpassword) {
			$result = $this -> field('password') -> getByuid($uid);
			if($result['newpassword'] != md5($oldpassword)) {
				return false;
			} else {
				$data['password'] = md5($newpassword);
				$result = $this -> where('uid='.$uid) -> save($data);
				return $result;
			}
		}
	}